package com.example.hf_v1.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MpConfig {

    @Bean
    public MybatisPlusInterceptor getMybatisPlusInterceptor() {

        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //创建分页插件
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        interceptor.addInnerInterceptor(paginationInnerInterceptor);

        // 开启二级缓存
        //interceptor.addInnerInterceptor(new OptimizedMetaObjectHandlerInterceptor()); //添加插件

        // 开启乐观锁
       // interceptor.addInnerInterceptor(new OptimisticLockInterceptor()); //添加插件

        // 开启日志
        //interceptor.addInnerInterceptor(new MybatisPlusInterceptor.LogImpl()); //添加插件

        // 开启性能分析
        //interceptor.addInnerInterceptor(new PerformanceInterceptor()); //添加插件

        // 开启 SQL 执行前后事件
        //interceptor.addInnerInterceptor(new SqlExecutionInterceptor()); //添加插件

        // 开启 SQL 注入器
        //interceptor.addInnerInterceptor(new InjectionInterceptor()); //添加插件

        // 开启乐观锁
       // interceptor.addInnerInterceptor(new OptimisticLockInterceptor()); //添加插件

        // 开启性能分析
        //interceptor.addInnerInterceptor
        return interceptor;

    }
}
